<template>
 <div class="wrapper">
  <swiper :options="swiperOption" v-if="showSwiper">
    <swiper-slide v-for='item of list' :key="item.id">
    <img class="swiper-img" :src="item.imgUrl" :alt="item.altContent">
    </swiper-slide>
    <div class="swiper-pagination" slot="pagination"></div>
  </swiper>
 </div>
</template>

<script>
export default {
  name: 'HomeSwiper',
  props: {
    list: Array
  },
  computed: {
    // 根据返回的长度来进行显示, 0为false,大为true则显示
    showSwiper () {
      return this.list.length
    }
  },
  data () {
    return {
      notNextTick: true,
      swiperOption: {
        pagination: '.swiper-pagination',
        loop: true
      }
    }
  }
}
</script>

<style lang="stylus" scoped>
  .wrapper >>> .swiper-pagination-bullet-active
      background: #fff !important
  .wrapper
    overflow: hidden
    height: 0
    width: 100%
    // background-size: 100% 100%;
    padding-bottom: 30.7%
    background: #eee
    .swiper-pagination
      width: 100%
      heigth: 10rem
    .swiper-img
      width: 100%
</style>
